import React from "react";
import Form from "../Form";

function windowWidthHoc(Component) {

    class WrappedComponent extends React.Component{
        state = {
            windowWidth :window.innerWidth,
        }
        gitWidth=() => {
            const windowWidth = window.innerWidth;
            this.setState({windowWidth});
        }
        componentDidMount() {
            window.addEventListener('resize',this.gitWidth)
        }
        componentWillUnmount() {
            window.removeEventListener('resize',this.gitWidth)
        }
        render() {
            const {windowWidth} = this.state;
            return(<Component {...this.props} windowWidth={windowWidth}
            ></Component>)
        }
    }
    return WrappedComponent;
}

export default windowWidthHoc;